<template>
	<view class="aaa">
		<image class="bg" src="@/static/bg_bt.png" mode=""></image>
		<view class="home">
			<image class="list" src="@/static/images/list_bg_01.png" mode=""></image>
			<view class="dian">
				<view class="one">
					<image src="../../static/images/one_s_03.png" mode=""></image>
					<text class="bottom">课程</text>
				</view>
				<view class="one">
					<image src="../../static/images/two_03.png" mode=""></image>
					<text class="bottom">大师课</text>
				</view>
				<view class="one">
					<image src="../../static/images/three_03.png" mode=""></image>
					<text class="bottom">体验课</text>
				</view>
			</view>
		</view>
		<view class="tuijian">
			<view class="tuijian_top">
				<view class="tuijian_left">
					推荐课程
				</view>
				<view class="tuijian_right">
					<view class="quanbu">
						全部{{countse}}个课程
					</view>
					<!-- <text class=""></text> -->
				</view>
			</view>
			<view class="tuijian_bottom">
				<view class="tow" v-for="(item,index) in typeData" :key="index">
					<!-- <image src="../../static/images/centent_03.jpg" mode=""></image> -->
					<image class="img" :src="'http://apis.90000p.com/fkm/upload/'+item.teacherPhoto" mode=""></image>
					<text class="tow_bottom">{{item.name}}</text>
				</view>
			</view>
		</view>
		<view class="jinri">
			<view class="jinri_top">
				<view class="jinri_left">
					今日课程
				</view>
				<view class="jinri_right">
					全部{{counts}}个课程
				</view>
			</view>
			<view class="jinri_bottom">
				<view class="three" v-for="(item,index) in listData" :key="index">
					<view class="three_left">
						<view class="three_left_left">
							<!-- <image src="../../static/images/semll_img_07.jpg" mode=""></image> -->
							<image class="left_img" :src="'http://apis.90000p.com/fkm/upload/'+item.teacherPhoto" mode=""></image>
						</view>
						<view class="three_left_right">
							<view class="one_box">
								{{item.name}}
							</view>
							<view class="tow_box">
								{{item.address}}
							</view>
							<view class="three_box">
								{{item.courseEndTime.substr(0,11)}} - {{item.courseStartTime.substr(0,11)}}
							</view>
						</view>
					</view>
					<view class="three_right">
						预约
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {coursesList} from '@/apis/index.js'
	export default {
		data() {
			return {
				query:{
					page:1,
					psize:5,
				},
				form:{
					page:1,
					psize:4,
					type:1
				},
				listData:[],
				pageCounts:1,
				counts:'',
				countse:'',
				typeData:[]
			}
		},
		onLoad() {
			this.getcourses()
			this.typeTwo()
		},
		// 上拉触底
		onReachBottom() {
			this.query.page++
			if(this.query.page>this.pageCounts){
				return uni.showToast({
					title:'没有更多了',
					icon:'none'
				})
			}
			this.getcourses()
		},
		// 刷新
		onPullDownRefresh() {
			this.query.page=1
			this.getcourses()
			uni.stopPullDownRefresh()
		},
		methods: {
			async typeTwo(){
				let res = await coursesList(this.form)
				console.log(res);
				this.typeData = res.data.list
				this.countse = res.data.counts
			},
			async getcourses(){
				let res = await coursesList(this.query)
				console.log(res);
				this.pageCounts = res.data.pageCounts
				this.counts = res.data.counts
				this.listData =this.query.page==1?res.data.list:[...this.listData,...res.data.list]
			},
		}
	}
</script>

<style>
	@import url(./home.less);
</style>
